package com.develop.skwen.yourelectricmall.activity.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.develop.skwen.yourelectricmall.fragment.category.CategoryFragment;
import com.develop.skwen.yourelectricmall.fragment.home.HomeFragment;
import com.develop.skwen.yourelectricmall.fragment.mine.MineFragment;
import com.develop.skwen.yourelectricmall.fragment.shop.ShopFragment;

/**
 * Created by skwen
 * on 18-4-24
 */

public class MainFragmentAdapter extends FragmentPagerAdapter {

    private String[] mTitles = new String[]{"首页", "分类", "购物车", "我的"};


    public MainFragmentAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 1) {
            return new CategoryFragment();
        } else if (position == 2) {
            return new ShopFragment();
        } else if (position == 3) {
            return new MineFragment();
        }
        return new HomeFragment();
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
